class Solution:
    def __init__(self):
        self.hex_dict = {0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9', 10: 'a',
                         11: 'b', 12: 'c', 13: 'd', 14: 'e', 15: 'f'}

    def toHex(self, num: int) -> str:
        if num == 0:
            return "0"
        res = ""
        if num < 0:
            num += 2 ** 32
        while num:
            res = self.hex_dict[num & 15] + res
            num = num >> 4
        return res


a = Solution()
print(a.toHex(26))
print(a.toHex(-1))
